﻿namespace DotNetUtility.GenericDesignPattern.Test
{
    using System;
    using System.Collections.Generic;
    using DotNetUtility.GenericDesignPattern;
    using NUnit.Framework;

    [TestFixture]
    public class StrategyOfMethodSelectionTest
    {
        enum MyEnum
        {
            None = 0,
            One,
            Two
        }

        [Test]
        public void StrategyOfMethodSelection()
        {
            Action methodOne = () => { Console.WriteLine("Method One"); };
            Action methodTwo = () => { Console.WriteLine("Method Two"); };
            Action doNothing = () => { return; };

            StrategyOfMethodSelection<MyEnum> strategyOfSelection = new StrategyOfMethodSelection<MyEnum>(
                new Dictionary<MyEnum, Action>() 
                {
                    {MyEnum.One, methodOne},
                    {MyEnum.Two, methodTwo},
                    {MyEnum.None, doNothing},

                }
                );
            Assert.AreEqual(methodOne, strategyOfSelection.GetSelectedMethod(MyEnum.One));
            Assert.AreEqual(methodTwo, strategyOfSelection.GetSelectedMethod(MyEnum.Two));
            Assert.AreEqual(doNothing, strategyOfSelection.GetSelectedMethod(MyEnum.None));
        }
    }
}
